package com.up.vms.infrastructure.job;

import lombok.Data;

import java.io.Serializable;

/**
 * Created by wangshd on 2018/12/5.
 */
@Data
public class JobParameter implements Serializable{

    private static int jobGroup;		// 执行器主键ID	(JobKey.group)
    private String jobCron;		// 任务执行CRON表达式 【base on quartz】
    private String jobDesc;
    private String author;		// 负责人

    private static String executorRouteStrategy;	// 执行器路由策略
    private static String executorHandler;		    // 执行器，任务Handler名称
    private String executorParam;		    // 执行器，任务参数
    private static String executorBlockStrategy;	// 阻塞处理策略
    private static String executorFailStrategy;	// 失败处理策略
    private static String glueType;

    public static  JobParameter getInstance(){
        return new JobParameter();

    }

    public  JobParameter init(JobConfiguration jobConfiguration){
        executorBlockStrategy = jobConfiguration.getExecutorBlockStrategy();
        executorFailStrategy = jobConfiguration.getExecutorFailStrategy();
        executorHandler = jobConfiguration.getExecutorHandler();
        glueType = jobConfiguration.getGlueType();
        executorRouteStrategy = jobConfiguration.getExecutorRouteStrategy();
        jobGroup = jobConfiguration.getJobGroup();
        return this;
    }

    public JobParameter setJobCron(String jobCron){
        this.jobCron = jobCron;
        return this;
    }

    public JobParameter setJobDesc(String jobDesc){
        this.jobDesc = jobDesc;
        return this;
    }

    public JobParameter setAuthor(String author){
        this.author = author;
        return this;
    }

    public JobParameter setExecutorParam(String executorParam){
        this.executorParam = executorParam;
        return this;
    }

    protected static int getJobGroup() {
        return jobGroup;
    }

    protected static String getExecutorRouteStrategy() {
        return executorRouteStrategy;
    }

    protected static String getExecutorHandler() {
        return executorHandler;
    }

    protected static String getExecutorBlockStrategy() {
        return executorBlockStrategy;
    }

    protected static String getExecutorFailStrategy() {
        return executorFailStrategy;
    }

    protected static String getGlueType() {
        return glueType;
    }

}
